#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "config.h"
#include <QRect>
#include <QScrollArea>
//#include "constantes.h"

/**
 * @class MainWindow
 * @brief Classe de description de la fenêtre principale
 * @date 10 aout 2013
**/
MainWindow::MainWindow(QWidget *parent) :QMainWindow(parent),ui(new Ui::MainWindow)

{
    barre_info=statusBar();
    /*Création du timer*/
    time_refresh=new QTimer;
    QString req;
    req="";
    req.append(url_www);
    req.append("/");
    req.append(tribune_xml_add);
    ui->setupUi(this);
    //barre_defil=new QScrollBar(ui->textEdit->verticalScrollBar());
    ui->label_site_info->setVisible(false);
    ui->sitename_view->setVisible(false);
    ui->num_user_var->setVisible(false);
    ui->User_num->setVisible(false);
    ui->UsersBox->setDisabled(true);
    ui->action_Stop->setDisabled(true);
    ui->actionLoad->setDisabled(true);
    connect(ui->action_Charger,SIGNAL(triggered()),this,SLOT(start_refresh()));
    connect(ui->action_Stop,SIGNAL(triggered()),this,SLOT(stop_refresh()));
    connect(ui->textEdit,SIGNAL(anchorClicked(QUrl)),this,SLOT(open_url(QUrl)));
    connect(ui->textEdit,SIGNAL(highlighted(QString)),this,SLOT(update_statusbar(QString)));
    connect(ui->actionConfiguration_Globale,SIGNAL(triggered()),this,SLOT(start_general_conf()));
    connect(ui->action_Configuration_des_tribunes,SIGNAL(triggered()),this,SLOT(acces_cnf_opts()));
    connect(ui->actionPlonkage,SIGNAL(triggered()),this,SLOT(plonk_list_conf_action()));
    connect(ui->action_A_propos,SIGNAL(triggered()),this,SLOT(acces_about()));
    connect(ui->actionA_propos_de_Qt,SIGNAL(triggered()),this,SLOT(acces_about_qt()));
    connect(ui->action_Updater,SIGNAL(triggered()),this,SLOT(access_refresh_board()));
    connect(ui->PostButton,SIGNAL(clicked()),this,SLOT(click_post_button()));
    connect(ui->boldbutton_bold,SIGNAL(clicked()),this,SLOT(click_bold_button()));
    connect(ui->underlined_button,SIGNAL(clicked()),this,SLOT(click_underlined_button()));
    connect(ui->strike_text_button,SIGNAL(clicked()),this,SLOT(click_strike_button()));
    connect(ui->anti_pwet_button,SIGNAL(clicked()),this,SLOT(click_anti_pwet_button()));
    connect(ui->no_bald_button,SIGNAL(clicked()),this,SLOT(click_anti_bald_button()));
    connect(ui->blam_button,SIGNAL(clicked()),this,SLOT(click_blam_button()));
    connect(ui->coin_coin_button,SIGNAL(clicked()),this,SLOT(click_coincoin_button()));
    connect(ui->joke_button,SIGNAL(clicked()),this,SLOT(click_joke_button()));
    connect(ui->button_moment,SIGNAL(clicked()),this,SLOT(click_moment_button()));
    connect(this,SIGNAL(end_posting()),this,SLOT(refresh_board()));
    connect(this,SIGNAL(end_refreshing()),this,SLOT(down_posts()));
    connect(this,SIGNAL(send_message_info(QString)),this,SLOT(update_statusbar(QString)));
    emit envoi_vers_cnf_add(req);
    emit envoi_vers_cnf_cookie(cookie);
    emit envoi_vers_cnf_post_add(post_url_add);
    emit envoi_vers_cnf_xml_path(tribune_xml_add);
    emit envoi_vers_cnf_ua(useragent_setting);
    emit envoi_vers_cnf_ua_value_choice(ua_value);
    emit envoi_vers_cnf_bool_order(sort_posts_in_order);
    emit envoi_vers_cnf_time(time);
    //Connection du nom du site vers la fonction qui le recupère a partir du parser
    ui->action_Charger->setEnabled(false);
}
void MainWindow::load_board_with_timer()
{
    ConfigBoardOptions *cnf= new ConfigBoardOptions;

    connect(cnf,SIGNAL(send_time_value(int)),this,SLOT(get_time_value_from_cnf(int)));
    connect(time_refresh, SIGNAL(timeout()),this, SLOT(updating()));
    connect(time_refresh,SIGNAL(destroyed()),time_refresh,SLOT(deleteLater()));
    emit send_message_info("Mise à jour");
    time_refresh->start(1000*time);
    ui->action_Charger->setDisabled(1);
    ui->action_Stop->setEnabled(1);
    update_activated=true;
}

/**
 * @fn void refresh_board(void)
 * @brief Fonction de rafraichissement de la tribune en mode manuel
 * @param none
 * @returns none method
 */
void MainWindow::refresh_board()
{ 
    qDebug()<<"Valeurs configurées\n";
    qDebug()<<url_www;
    qDebug()<<tribune_xml_add;
    http_client *http=new http_client;
    parser *parse=new parser;
    ConfigBoardOptions *cnf= new ConfigBoardOptions;
    QString req;

    req="";
    req.append(url_www);
    req.append("/");
    req.append(tribune_xml_add);
    qDebug()<<"Addresse :\n";
    qDebug()<<req;
    qDebug()<<"recup du doc";
    if((url_www=="")|(tribune_xml_add==""))
    {
        cnf->show();

    }
    else
    {
        http->http_request_get(url_www,tribune_xml_add,useragent_setting);
    }
    connect(cnf,SIGNAL(send_config_data_val_xml_path(QString)),this,SLOT(get_conf_xml_path(QString)));
    connect(cnf,SIGNAL(send_config_data_val_add(QString)),this,SLOT(get_conf_add(QString)));
    connect(cnf,SIGNAL(send_config_data_val_cookie(QString)),this,SLOT(get_conf_cookie(QString)));
    connect(cnf,SIGNAL(send_config_data_val_post_url(QString)),this,SLOT(get_conf_post_add(QString)));
    connect(cnf,SIGNAL(send_reverse_post_checked(bool)),this,SLOT(get_bool_cnf(bool)));
    connect(cnf,SIGNAL(send_time_value(int)),this,SLOT(get_time_value_from_cnf(int)));
    connect(http,SIGNAL(send_filename_from_url(QString)),this,SLOT(get_filename_parsing(QString)));
    connect(http,SIGNAL(send_filename_with_url(QString)),this,SLOT(get_name_file_with_add(QString)));
    connect(http,SIGNAL(send_content(QString)),this,SLOT(get_content_board(QString)));
    connect(this,SIGNAL(envoi_vers_parse_order(bool)),parse,SLOT(bool_order_post(bool)));
    connect(http,SIGNAL(send_content_req_to_parse(const QByteArray)),parse,SLOT(get_content_from_http(const QByteArray)));
    connect(http,SIGNAL(send_state_http_get(int)),this,SLOT(get_state_parsing(int)));
    connect(parse,SIGNAL(emit_parsing_state(int)),this,SLOT(get_state_parsing(int)));
    connect(this,SIGNAL(envoi_vers_parse_order(bool)),parse,SLOT(bool_order_post(bool)));
    qDebug()<<"fichier_xml_with_add ="<<fichier_xml_with_add;
    connect(parse,SIGNAL(send_users_number(int)),this,SLOT(get_number_users(int)));
    connect(parse,SIGNAL(send_site_value(QString)),this,SLOT(get_site_name_from_xml(QString)));
    connect(parse,SIGNAL(send_board_data_decoded(QString)),this,SLOT(get_content_board(QString)));
    connect(parse,SIGNAL(send_users_list(QStringList,QStringList)),this,SLOT(get_users_list(QStringList,QStringList)));
    connect(this,SIGNAL(envoi_parametres_vers_client_http_get(QString,QString,QString)),http,SLOT(network_get_request(QString,QString,QString)));
    //connect(this,SIGNAL(send_message_info(QString)),this,SLOT(update_statusbar(QString)));
    qDebug()<<"req:"<<req<<"\n\r cookie:"<<cookie<<"\n\rpost_url_add"<<post_url_add;
    if(update_activated==false)
    {
        emit envoi_vers_cnf_add(req);
        emit envoi_vers_cnf_cookie(cookie);
        emit envoi_vers_cnf_post_add(post_url_add);
        emit envoi_vers_cnf_xml_path(tribune_xml_add);
        emit envoi_vers_cnf_ua(useragent_setting);
        emit envoi_vers_parse_order(sort_posts_in_order);
    }

    connect(this,SIGNAL(end_refreshing()),this,SLOT(descente_posts()));
    connect(this,SIGNAL(end_refreshing()),this,SLOT(compare_state()));
    connect(http,SIGNAL(finish_export()),http,SLOT(detruire_response()));
    old_message_state=ui->textEdit->toPlainText();
    ui->sitename_view->setVisible(true);
    ui->label_site_info->setVisible(true);
    ui->User_num->setVisible(true);
    ui->num_user_var->setVisible(true);
    ui->UsersBox->setEnabled(true);
    ui->UsersBox->setEditTriggers(QAbstractItemView::NoEditTriggers);

    connect(this,SIGNAL(end_refreshing()),http,SLOT(deleteLater()));
    connect(this,SIGNAL(end_refreshing()),parse,SLOT(deleteLater()));
}
/**
 * @fn void show_config_assistant(void)
 * @brief Méthode qui appelle l'assistant de configuration du soft
 * @param none
 * @returns none
 */
void MainWindow::show_config_assistant()
{
    config *cnf_file =new config;
    ConfigBoardOptions *cnf_opts=new ConfigBoardOptions;
    connect(cnf_opts,SIGNAL(send_config_data_val_add(QString)),this,SLOT(get_conf_add(QString)));
    connect(cnf_opts,SIGNAL(send_config_data_val_cookie(QString)),this,SLOT(get_conf_cookie(QString)));
    connect(cnf_opts,SIGNAL(send_config_data_val_xml_path(QString)),this,SLOT(get_conf_xml_path(QString)));
    connect(cnf_opts,SIGNAL(send_config_data_val_post_url(QString)),this,SLOT(get_conf_post_add(QString)));
    connect(cnf_opts,SIGNAL(send_config_data_val_user_agent(QString)),this,SLOT(get_conf_ua(QString)));
    connect(cnf_opts,SIGNAL(send_type_board(QString)),this,SLOT(get_conf_board_type(QString)));
    connect(cnf_opts,SIGNAL(send_user_name(QString)),this,SLOT(get_user_post_name(QString)));
    connect(cnf_opts,SIGNAL(send_ua_value_select(int)),this,SLOT(get_user_agent_value(int)));
    connect(cnf_opts,SIGNAL(send_time_value(int)),this,SLOT(get_time_value_from_cnf(int)));
    connect(cnf_opts,SIGNAL(send_config_data_val_add(QString)),cnf_file,SLOT(receive_data_add_from_cnf(QString)));
    connect(cnf_opts,SIGNAL(send_config_data_val_cookie(QString)),cnf_file,SLOT(receive_data_cookie_from_cnf(QString)));
    connect(cnf_opts,SIGNAL(send_config_data_val_user_agent(QString)),cnf_file,SLOT(receive_data_user_agent_from_cnf(QString)));
    connect(cnf_opts,SIGNAL(send_config_data_val_post_url(QString)),cnf_file,SLOT(receive_data_post_path_from_cnf(QString)));
    connect(cnf_opts,SIGNAL(send_config_data_val_xml_path(QString)),cnf_file,SLOT(receive_data_xml_path_from_cnf(QString)));
    connect(cnf_opts,SIGNAL(send_type_board(QString)),cnf_file,SLOT(receive_data_post_scheme_from_cnf(QString)));
    connect(cnf_opts,SIGNAL(emit_fermeture()),cnf_file,SLOT(write_conf_board_init()));
    connect(this,SIGNAL(envoi_vers_cnf_add(QString)),cnf_opts,SLOT(recoit_de_main_add(QString)));//add
    connect(this,SIGNAL(envoi_vers_cnf_cookie(QString)),cnf_opts,SLOT(recoit_de_main_cookie(QString)));//cookie
    connect(this,SIGNAL(envoi_vers_cnf_ua(QString)),cnf_opts,SLOT(recoit_de_main_ua(QString)));//ua
    connect(this,SIGNAL(envoi_vers_cnf_xml_path(QString)),cnf_opts,SLOT(recoit_de_main_xml_path(QString)));//xml path
    connect(this,SIGNAL(envoi_vers_cnf_message_type(QString)),cnf_opts,SLOT(recoit_de_main_tribune_post_type(QString)));//message type
    connect(this,SIGNAL(envoi_vers_cnf_post_add(QString)),cnf_opts,SLOT(recoit_de_main_post_url(QString)));//post url
    connect(this,SIGNAL(envoi_vers_cnf_user_name_post(QString)),cnf_opts,SLOT(recoit_de_main_user_name(QString)));
    connect(this,SIGNAL(envoi_vers_cnf_ua_value_choice(int)),cnf_opts,SLOT(recoit_de_main_ua_value(int)));
    connect(this,SIGNAL(envoi_vers_cnf_bool_order(bool)),cnf_opts,SLOT(recoit_de_main_bool_set(bool)));
    connect(this,SIGNAL(envoi_vers_cnf_time(int)),cnf_opts,SLOT(recoit_de_main_time(int)));
    //Envoi des signaux
    emit envoi_vers_cnf_add(url_www);//add
    emit envoi_vers_cnf_cookie(cookie);//cookie
    emit envoi_vers_cnf_message_type(message_string_value);//message type
    emit envoi_vers_cnf_post_add(post_url_add);//url de post
    emit envoi_vers_cnf_xml_path(tribune_xml_add);//xml path
    emit envoi_vers_cnf_ua(useragent_setting);//ua
    emit envoi_vers_cnf_user_name_post(user_name_post);//nom d'utilisateur
    //emit envoi_parametres_vers_client_http_get(url_www,tribune_xml_add,useragent_setting);
    qDebug()<<"Ouverture de la fenetre de configuration";
    cnf_opts->show();
    ui->action_Stop->setDisabled(true);
    ui->action_Charger->setEnabled(true);
}
/**
 * @fn void start_global_conf(void)
 * @brief Méthode qui affiche la fenètre de conf du logiciel
 * @param none
 * @returns none
 */
void MainWindow::start_general_conf()
{
    generalsettings *conf_gen=new generalsettings;
    conf_gen->show();
}

/**
 * @fn void about_window(void)
 * @brief Méthode qui affiche la version du logiciel
 * @param none
 * @returns none
 */
void MainWindow::about_window()
{
    //QMessageBox()
    AboutWindow *about_win =new AboutWindow;
    about_win->show();
}
/**
 * @fn void version_qt(void)
 * @brief Méthode qui affiche la version de Qt
 * @param none
 * @returns none
 */
void MainWindow::version_qt()
{
    QMessageBox::aboutQt(this, tr("A propos de Qt "));
}
/**
 * @fn void version_qt(void)
 * @brief Méthode qui configure l'adresse qui sera utilisé par les fonctions posts et get
 * @param none
 * @returns none
 */
void MainWindow::setadress()
{
    //tribune_xml_add.setRawData(ui->)
    //tribune_xml_add=
}
/**
 * @fn void get_xml_file_name(void)
 * @brief Méthode qui récupère l'adresse de la tribune
 * @param none
 * @returns none
 */

void MainWindow::set_site_name_parse()
{
    //parser *par=new parser;
    //par->access_site_name(site_name_url);

}
/**
 * @fn void post_action(QString add, QString post_url_add, QString message, QString cookie_val)
 * @brief Méthode qui poste sur la tribune
 * @param add Addresse du site
 * @param post_url url de post
 * @param message message a poster
 * @param cookie_val cookie de l'utilisateur
 * @returns none
 */
void MainWindow::post_action(QString add, QString post_url_add, QString message, QString cookie_val)
{
    http_client *http =new http_client;
    connect(http,SIGNAL(end_posting()),this,SLOT(get_post_inf_end()));
    connect(http,SIGNAL(end_posting()),this,SLOT(updating()));
    connect(http,SIGNAL(end_posting()),http,SLOT(detruire_response_post()));
    QString message_data=message_string_value;
    message_data.append(message);
    http->http_request_post(add,post_url_add,message_data,cookie_val,useragent_setting);
    message_data="";
    message="";
    emit end_posting();
}
void MainWindow::get_parmeters()
{
    /*ConfigBoardOptions *fen_conf= new ConfigBoardOptions;
    url_www.append(fen_conf->access_add());
    tribune_xml_add.append(fen_conf->access_xml_path());
    cookie.append(fen_conf->access_cookie());
    post_url_add.append(fen_conf->access_post_path());
    qDebug()<<post_url_add;*/

}

void MainWindow::acces_cnf_opts()
{
    show_config_assistant();
}
void MainWindow::acces_about()
{
    about_window();
}
void MainWindow::acces_about_qt()
{
    version_qt();
}
void MainWindow::access_refresh_board()
{
    refresh_board();
}
void MainWindow::run_board_timer()
{
    load_board_with_timer();
}

void MainWindow::show_site_name()
{
    set_site_name_parse();
}
void MainWindow::click_post_button()
{
    message_post=ui->post_textEdit->toPlainText();
    //message_post.replace("%2B","'%2B'");
    message_post.replace("+","%2B");

    //Anti flood pour décourager les gros boulets
    if(message_post=="")
    {

        ui->post_textEdit->setText("");//Anti flood
        qDebug()<<"Post vide impossible de poster";
    }
    else
    {
#if QT_VERSION >= 0x0500
        post_action(url_www,post_url_add,message_post.toLatin1(),cookie);
#else
        post_action(url_www,post_url_add,message_post.toAscii(),cookie);
#endif
        refresh_board();
        qDebug()<<"Post du message :"<<message_post;


    }

    ui->post_textEdit->setText("");//Anti flood
    //connect(this,SIGNAL(end_posting()),http,SLOT(deleteLater()));
    connect(this,SIGNAL(end_posting()),this,SLOT(updating()));
    //Fin de post
    //updating();
    //refresh_board();
    emit end_posting();

}
/**
 * @fn void compare_content(void)
 * @brief Méthode de comparaison du contenu du backend
 * @param add Addresse du site
 * @param post_url url de post
 * @param message message a poster
 * @param cookie_val cookie de l'utilisateur
 * @returns none
 */
void MainWindow::compare_state()
{

    if(messages!=old_message_state)
    {
        emit send_message_info("Nouveau post!");
        qDebug()<<"Le contenu à changé!";
        qApp->alert(this);

    }
    else{

    }

}

void MainWindow::get_cookie(QString value)
{
    cookie=value;
}
void MainWindow::get_address(QString value)
{
    url_www=value;
}
void MainWindow::get_post_url(QString value)
{
    post_url_add=value;
}
void MainWindow::get_xml_file_name(QString value)
{
    tribune_xml_add=value;
}
void MainWindow::get_conf_add(QString value)
{
    url_www=value;
}
void MainWindow::get_conf_cookie(QString value)
{
    cookie=value;
}
void MainWindow::get_conf_post_add(QString value)
{
    post_url_add=value;
}
void MainWindow::get_conf_xml_path(QString value)
{
    tribune_xml_add=value;
}
void MainWindow::get_req_add(QString value)
{
    url_full=value;
}
void MainWindow::get_conf_ua(QString value)
{
    useragent_setting=value;
}
void MainWindow::get_conf_board_type(QString value)
{
    message_string_value=value;
}
void MainWindow::get_filename_parsing(QString value)
{
    fichier_xml=value;
}
void MainWindow::get_user_post_name(QString name)
{
    user_name_post=name;
}

void MainWindow::get_content_board(QString content)
{

    if(content=="")
    {
        qDebug()<<"Fail";
    }
    else
    {
        ui->textEdit->setHtml(content);
        messages=ui->textEdit->toPlainText();
        ui->textEdit->verticalScrollBar()->setSliderPosition(ui->textEdit->verticalScrollBar()->maximum());

    }

    emit end_refreshing();

}
void MainWindow::get_site_name_from_xml(QString value)
{
    ui->sitename_view->setText(value);
}
void MainWindow::get_name_file_with_add(QString value)
{
    fichier_xml_with_add=value;
}
void MainWindow::get_number_users(int value)
{
    ui->num_user_var->setText(QString().setNum(value,10));
}
void MainWindow::get_plonk_users(QStringList plonkusers)
{
    plonk=plonkusers;
}
void MainWindow::plonk_list_conf_action()
{
    DialogPlonk *plonk_cnf=new DialogPlonk;
    plonk_cnf->show();
}

void MainWindow::refresh_time(int time)
{
    time=0;
}
void MainWindow::parsing()
{

}
void MainWindow::click_bold_button()
{
    message_post=ui->post_textEdit->toPlainText();
    message_post.prepend("<b>");
    message_post.append("</b>");
    ui->post_textEdit->setText(message_post);
}
void MainWindow::click_italic_button()
{
    message_post=ui->post_textEdit->toPlainText();
    message_post.prepend("<i>");
    message_post.append("</i>");
    ui->post_textEdit->setText(message_post);
}
void MainWindow::click_underlined_button()
{
    message_post=ui->post_textEdit->toPlainText();
    message_post.prepend("<u>");
    message_post.append("</u>");
    ui->post_textEdit->setText(message_post);
}
void MainWindow::click_strike_button()
{

    message_post=ui->post_textEdit->toPlainText();
    message_post.prepend("<s>");
    message_post.append("</s>");
    ui->post_textEdit->setText(message_post);
}
void MainWindow::click_anti_bald_button()
{
    ui->post_textEdit->setText("sale chauve");
}
void MainWindow::click_anti_pwet_button()
{
    ui->post_textEdit->setText("Ta gueule pwet !");
}
void MainWindow::click_blam_button()
{
    ui->post_textEdit->setText("_o/ <b>BLAM</b>!");
}
void MainWindow::click_coincoin_button()
{
    ui->post_textEdit->setText(ui->post_textEdit->toPlainText().append(" \\_o<"));
}
void MainWindow::click_joke_button()
{
    ui->post_textEdit->setText("blague<");
}
void MainWindow::click_moment_button()
{
    message_post=ui->post_textEdit->toPlainText();
    message_post.prepend("====>Moment ");
    message_post.append("<====");
    ui->post_textEdit->setText(message_post);
}
void MainWindow::pause_refresh()
{
    if(time_refresh->isActive())
    {
        time_refresh->stop();
    }
}

void MainWindow::get_users_list(QStringList users,QStringList ua)
{
    users.removeDuplicates();//Retrait des doublons
    for(int i=0;i<users.size();i++)
    {
        if(users.at(i)==0)
        {
            //Prévoir la même chose pour la liste des users dans la mainwindow
            if(ua.at(i).size()<15)
            {
                users[i]=ua.at(i);
            }
            else
            {
                users[i]="Anonymes";
            }
        }
    }
    connected_users_list_model=new QStringListModel(users);
    ui->UsersBox->setModel(connected_users_list_model);
    connected_users_list_model->setStringList(users);
}
void MainWindow::get_user_agents_list(QStringList ua_list)
{
    users_agents_list=ua_list;
}
void MainWindow::get_user_agent_value(int value)
{
    ua_value=value;
}
void MainWindow::open_url(QUrl url)
{
    //Ouvertue de l'url avec le browser par défaut

    browserlaunch.openUrl(url);
}
void MainWindow::get_bool_cnf(bool config_val)
{
    sort_posts_in_order=config_val;
}
void MainWindow::get_and_set_sitename(QString site)
{
    ui->sitename_view->setText(site);
}
void MainWindow::get_time_value_from_cnf(int value)
{
    time=value;
}
void MainWindow::updating()
{
    refresh_board();
}
/*!
 * \brief MainWindow::stop_refresh
 */

void MainWindow::stop_refresh()
{

    ui->action_Stop->setDisabled(1);
    ui->action_Charger->setEnabled(1);
    //connect(time_refresh,SIGNAL(destroyed()),time_refresh,SLOT(delete()));
    time_refresh->stop();
    update_activated=false;
    //time_refresh->deleteLater();
    //time_refresh->de
    //delete time_refresh;
}
void MainWindow::update_statusbar(QString info)
{
    barre_info=statusBar();
    barre_info->showMessage(info,10000);
}

void MainWindow::start_refresh()
{
    load_board_with_timer();
}
void MainWindow::get_post_inf_end()
{
    refresh_board();//Mise

}
void MainWindow::descente_posts()
{
    int val_max_ascenseur=ui->textEdit->verticalScrollBar()->maximum();
    ui->textEdit->verticalScrollBar()->setValue(val_max_ascenseur);

}
void MainWindow::get_state_parsing(int value)
{
    switch(value)
    {
    case 0:
        emit send_message_info("Erreur réseau");
        break;
    case 1:
        emit send_message_info("Pas d'erreurs");
        break;
    case 2:
        emit send_message_info("Parsing en cours");
        break;
    case 3:
        emit send_message_info("Parsing fini");
        break;
    case 4:
        emit send_message_info("Erreur de parsing");
        break;

    }

}
/**
 * @fn void new_posts(void)
 * @brief Évenents se déclanchnant a un nouveau post
 * @param none
 * @returns none method
 */
void MainWindow::new_post()
{

    emit send_message_info("Nouveau(x) post(s)");
}
void MainWindow::down_posts(){

    //ui->textEdit->verticalScrollBar()->setValue(ui->textEdit->verticalScrollBar()->maximum());
    //barre_defil->setValue(barre_defil->max);

}

MainWindow::~MainWindow()
{
    delete ui;
    delete time_refresh;
}

